package com.example.shopping.user;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RefreshScope  //开启动态读取配置
@RestController
@RequestMapping("/api")
public class ConfigController {

    @Value("${shopping.user.name}")
    private String name;

    @Value("${shopping.user.age}")
    private Integer age;

    @RequestMapping("/info")
    public Ret getInfo() {
        return Ret.success(new HashMap<String, Object>() {{
            this.put("name", name);
            this.put("age", age);
        }});
    }

}
